#!/usr/bin/env bash
# yitong.bai@qq.com

function OsToolsInstallRole() {
  InstallCommandIfNotInstalled "wget" || (warn "WARN: Install command wget ERROR, exit now!" && return 1)
  InstallCommandIfNotInstalled "git" || (warn "WARN: Install command git ERROR, exit now" && return 1)
  InstallCommandIfNotInstalled "createrepo" || (warn "WARN: Install command create ERROR, exit now" && return 1)

  info "INFO: Installed some system tools."
}

function BootstrapOsRole() {
  LoadFunctionsByOperatingSystemId
  LoadRolesByOperatingSystemId

  ( AmIRoot & MayIAccessTheInternet && info "INFO: I'm root, and I could access the internet!" ) \
  || \
  ( error "ERROR: I am not root, I can't access the internet, exit now!" && return 1 )

  ( DisableSELinuxIfNotDisabled && info "INFO: SELinux is disabled.") \
  || continue 
  # ( error "ERROR: SELinux disable ERROR, exit now." && return 1)

  (DisableFirewalldIfNotDisabled && info "INFO: Firewalld is disabled." ) \
  || \
  ( error "ERROR: Firewalld disable ERROR, exit now." && return 1)

  ( OnlineConfigurationSetupRole && info "INFO: Configured repo to online mode." ) \
  || \
  ( error "ERROR: ERROR to Configure Repo to online mode, exit now." && return 1)
  
  OsToolsInstallRole
}
